<?php
include 'phpmailer/class.phpmailer.php';
include "inc/implement.php";

if ($_POST['uloz_zam_bmb'] == 1) {
    pristup("admin");
    $ak_edit = IntVal($_GET['zid']);
    pridat_zamestnanca_bmb_uloz("$ak_edit");
}

if ($_POST['uloz_spol'] == 1) {
    pristup("admin");
    $ak_edit = IntVal($_GET['spolid']);
    pridat_spolocnost_uloz("$ak_edit");
}

if ($_POST['uloz_prisp'] == 1) {
    pristup("admin");
    pridat_prispievatela_uloz();
}

if ($_POST['uloz_zam_spol'] == 1) {
    pristup("user");
    pridat_zamestnanca_spol_uloz((($falkMode) && ($falkAdmin)));
}

if ($_POST['uloz_zam_spol_3'] == 1) {
    pristup("user");
    profil_zamestnanec_spol3_uloz();
}

if ($_POST['uloz_zam_spol_3_up'] == 1) {
    pristup("user");
    profil_zamestnanec_spol3_uprava_uloz();
}

if (!Empty($_GET['b'])) {
    $zobraz = IntVal($_GET['zobraz']);
    $back = IntVal($_GET['b']);
    zobraz_zam($zobraz, $back);
}

if (!Empty($_GET['sviatok'])) {
    pristup("admin");
    $zobraz = IntVal($_GET['zobraz']);
    zmen_sviat($zobraz);
}

if ($_POST['sviatky_pridat'] == 1) {
    pristup("admin");
    sviatok_pridaj();
}

if ($_GET['sviatok_del'] == 1) {
    pristup("admin");
    $sviatok = IntVal($_GET['s']);
    sviatok_vymazat($sviatok);
}

if ($_POST['uloz_vzor_doc'] == 1) {
    pristup("admin");
    vzor_dokument_admin_uloz();
}

if ($_POST['uloz_doc'] == 1) {
    pristup("user");
    dokument_user_uloz();
}

if ($_GET['del_doc_vzor'] == 1) {
    pristup("admin");
    $doc = IntVal($_GET['did']);
    vzor_dokument_vymazat($doc);
}

if ($_GET['zmen_doch'] == 1) {
    pristup("user");
    $zobr = Explode(",", $_GET['zobraz']);
    zmen_doch($zobr[0], $zobr[1]);
}

if ($_GET['zmen_kal'] == 1) {
    pristup("admin");
    $spolid = IntVal($_GET['spolid']);
    zmen_kal($spolid);
}

if ($_GET['zmen_kal_rok'] == 1) {
    pristup("admin");
    $zobraz = IntVal($_GET['zobraz']);
    zmen_kal_rok($zobraz);
}

if ($_POST['kalendar_pridat'] == 1) {
    pristup("admin");
    kalendar_uloz();
}

if ($_POST['doch_kal'] == 1) {
    pristup("user");
    if (!Empty($_POST['odovzd_doch_new']))
        $ajOdovzdat = 1;

    dochadzka_kalendar_sent($ajOdovzdat);

    if ($ajOdovzdat == 1)
        dochadzka_odovzdat_sent();
}

if ($_POST['doch_kal2'] == 1) {
    pristup("user");
    dochadzka_kalendar_sent2();
}

if ($_POST['doch_zoznam'] == 1) {
    pristup("user");
    dochadzka_zoznam_sent();
}

if ($_GET['neprit_zmaz'] == 1) {
    pristup("user");
    nepritomnost_zmazat();
}

if ($_POST['odovzdanie_doch'] == 1) {
    pristup("user");
    dochadzka_odovzdat_sent();
}

if ($_POST['heslo_new'] == 1) {
    heslo_sent();
}

if ($_GET['spracovane'] == 1) {
    pristup("zamestnanec");
    $co_ok = IntVal($_GET['co']);
    $did_ok = IntVal($_GET['did']);
    spracovany_doc($co_ok, $did_ok);
}

if ($_GET['bmb_zmen_spol'] == 1) {
    pristup("zamestnanec");
    $spolid_ok = IntVal($_GET['spolid']);
    $next_ok = IntVal($_GET['next']);
    bmb_vyber_spol_zmen($spolid_ok, $next_ok);
}

if ($_GET['bmb_zmen_stav'] == 1) {
    pristup("zamestnanec");
    $zobraz = IntVal($_GET['zobraz']);
    $vp = IntVal($_GET['vp']);
    bmb_zobraz_zam($zobraz, $vp);
}

if ($_GET['zmen_doch_x'] == 1) {
    pristup("zamestnanec");
    $zobr = Explode(",", $_GET['zobraz']);
    zmen_doch_x($zobr[0], $zobr[1]);
}

if ($_GET['del_subor_mzda'] == 1) {
    pristup("zamestnanec");
    $did_ok = IntVal($_GET['did']);
    del_subor_mzda_x($did_ok);
}

if ($_POST['uloz_14_doc'] == 1) {
    pristup("zamestnanec");
    doc_14_sent();
}

if ($_POST['jazyky_uloz'] == 1) {
    jazyky_sent();
}

if ($_GET['ch_lang'] == 1) {
    $lang_ok = IntVal($_GET['lang']);
    change_lang($lang_ok);
}

if ($_POST['vp_new'] == 1) {
    vp_new();
}

if ($_GET['akc'] == 15 && $_GET['akc2'] == 3 && !Empty($_GET['vpid'])) {
    $vpid = IntVal($_GET['vpid']);
    vp_del("$vpid");
}

if ($_GET['del_sdoc'] == 1) {
    pristup("user");
    $id = IntVal($_GET['id']);
    spol_docs_vymazat($id);
}

if ($_GET['logout'] == 1) {
    logout();
}

if (isset($_POST['upravitManazera'])) {
    upravitManazera($_POST['zid']);
}

if (isset($_POST['pridat_oddelenie'])) {
    pridatOddelenie($_POST['meno_oddelenia']);
}

if ($_GET['akc'] == 3) {
    pristup("user");
    if ($_GET['akc2'] == 4 && !Empty($_GET['zid']) && Empty($_GET['uprava']) && !Empty($_GET['neaktual'])) {
        $zid = IntVal($_GET['zid']);
        $neaktual = IntVal($_GET['neaktual']);
        profil_zamestnanec_spol3_neaktual("$zid", "$neaktual");
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk">
    <head>

        <meta http-equiv="content-language" content="sk" />
        <meta http-equiv="cache-control" content="no-cache" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>BMB Leitner CS</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
        <link rel="stylesheet" type="text/css" href="tabulka.css" />
        <script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>
        <script type="text/javascript" src="js/datetimepicker_css.js"></script>
        <script type="text/javascript" src="js/multifile.js"></script>
        <script type="text/javascript" src="js/fc.js"></script>

    </head>
    <body>

        <table cellspacing="0" cellpadding="0" width="100%"><tr><td>
                    <?php
                    menu();
                    echo "</td></tr><tr><td>\n";
                    if (Empty($_GET['akc'])) {
                        uvod();
                    } elseif ($_GET['akc'] == 1) {
                        pristup("admin");
                        if (Empty($_GET['akc2']) && Empty($_GET['spolid'])) {
                            zoznam_spolocnosti();
                        } elseif ($_GET['akc2'] == 1) {
                            $ak_edit = IntVal($_GET['spolid']);
                            pridat_spolocnost("$ak_edit");
                        } elseif (Empty($_GET['akc2']) && !Empty($_GET['spolid'])) {
                            $spolid = IntVal($_GET['spolid']);
                            profil_spolocnost("$spolid");
                        } elseif ($_GET['akc2'] == 2 && !Empty($_GET['spolid'])) {
                            $spolid = IntVal($_GET['spolid']);
                            zoznam_prispievatelov("$spolid");
                        } elseif ($_GET['akc2'] == 2 && !Empty($_GET['prispid'])) {
                            $prispid = IntVal($_GET['prispid']);
                            profil_prispievatela("$prispid");
                        } elseif ($_GET['akc2'] == 3 && (!Empty($_GET['spolid']) || !Empty($_GET['prispid']))) {
                            $spolid = IntVal($_GET['spolid']);
                            pridat_prispievatela("$spolid");
                        } elseif ($_GET['akc2'] == 4) {
                            vyber_spol_prisp();
                        } else {
                            
                        }
                    } elseif ($_GET['akc'] == 2) {
                        pristup("admin");
                        if (Empty($_GET['akc2']) && Empty($_GET['zid'])) {
                            zoznam_zamestnancov_bmb();
                        } elseif ($_GET['akc2'] == 1) {
                            $ak_edit = IntVal($_GET['zid']);
                            pridat_zamestnanca_bmb("$ak_edit");
                        } elseif ($_GET['akc2'] == 2 && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            vymazat_foto_zamestnanca_bmb("$zid");
                        } elseif (Empty($_GET['akc2']) && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            profil_zamestnanec_bmb("$zid");
                        } else {
                            
                        }
                    } elseif ($_GET['akc'] == 3) {
                        pristup("user");
                        if (Empty($_GET['akc2']) && Empty($_GET['zid'])) {
                            $spolid = spolid_prihlaseneho($veduci_oddelenia);
                            zoznam_zamestnancov_spol("$spolid", (($falkMode) && ($falkAdmin)));
                        } elseif ($_GET['akc2'] == 1) {
                            pridat_zamestnanca_spol((($falkMode) && ($falkAdmin)));
                        } elseif ($_GET['akc2'] == 2 && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            profil_zamestnanec_spol("$zid", (($falkMode) && ($falkAdmin)));
                        } elseif ($_GET['akc2'] == 3 && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            profil_zamestnanec_spol2("$zid", (($falkMode) && ($falkAdmin)));
                        } elseif ($_GET['akc2'] == 4 && !Empty($_GET['zid']) && Empty($_GET['uprava']) && Empty($_GET['neaktual'])) {
                            $zid = IntVal($_GET['zid']);
                            profil_zamestnanec_spol3("$zid", (($falkMode) && ($falkAdmin)));
                        } elseif ($_GET['akc2'] == 4 && !Empty($_GET['zid']) && !Empty($_GET['uprava']) && Empty($_GET['neaktual'])) {
                            $zid = IntVal($_GET['zid']);
                            $uprava = IntVal($_GET['uprava']);
                            profil_zamestnanec_spol3_uprava("$zid", "$uprava", (($falkMode) && ($falkAdmin)));
                        } elseif ($_GET['akc2'] == 4 && !Empty($_GET['zid']) && Empty($_GET['uprava']) && !Empty($_GET['neaktual'])) {
                            $zid = IntVal($_GET['zid']);
                            $neaktual = IntVal($_GET['neaktual']);
                            profil_zamestnanec_spol3_neaktual("$zid", "$neaktual");
                        }
                    } elseif ($_GET['akc'] == 4) {
                        pristup("user");
                        global $bodNula;
                        $bodNula = ZERO;
                        if (($falkMode) && ($falkAdmin)) {
                            include("manazeri.php");
                        } else if ($veduci_oddelenia) {
                            include("obycZam.php");
                        } else {
                            dochadzka();
                        }
                    } elseif ($_GET['akc'] == 77) {
                        pristup("user");
                        global $bodNula;
                        $bodNula = ZERO;
                        if (($falkMode) && ($falkAdmin)) {
                            if (isset($_POST['toExcel']))
                                header("vystupnaToExcel.php");
                            else
                                include("vystupna_dochadzka.php");
                        } else {
                            echo 'Nemáte prístup';
                        }
                    } elseif ($_GET['akc'] == 78) {
                        pristup("user");
                        if (($falkMode) && ($falkAdmin)) {
                            if (Empty($_GET['akc2']))
                                zoznam_oddeleni();
                            elseif ($_GET['akc2'] == 1) {
                                pridaj_oddelenie();
                            }
                        } else {
                            echo 'Nemáte prístup';
                        }
                    } elseif ($_GET['akc'] == 5) {
                        pristup("admin");
                        sviatky_zobraz();
                    } elseif ($_GET['akc'] == 6) {
                        pristup("admin");
                        vzor_dokument_admin();
                    } elseif ($_GET['akc'] == 7) {
                        pristup("user");
                        dokument_user();
                    } elseif ($_GET['akc'] == 8) {
                        pristup("admin");
                        kalendar();
                    } elseif ($_GET['akc'] == 44) {
                        pristup("admin");
                        include('blokovani.php');
                    } elseif ($_GET['akc'] == 45) {
                        pristup("zamestnanec");
                        include('blokovani.php');
                    } elseif ($_GET['akc'] == 91) {
                        //pristup ("zamestnanec");
                        include('vystupy.php');
                    } elseif ($_GET['akc'] == 9) {
                        heslo();
                    } elseif ($_GET['akc'] == 10) {
                        pristup("zamestnanec");
                        if (Empty($_GET['akc2']) && Empty($_GET['zid'])) {
                            zoznam_zamestnancov_spol_x();
                        } elseif ($_GET['akc2'] == 2 && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            profil_zamestnanec_spol_x("$zid");
                        } elseif ($_GET['akc2'] == 3 && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            profil_zamestnanec_spol2_x("$zid");
                        }
                    } elseif ($_GET['akc'] == 11) {
                        pristup("zamestnanec");
                        dokument_user_x();
                    } elseif ($_GET['akc'] == 12) {
                        pristup("zamestnanec");
                        global $bodNula;
                        $bodNula = ZERO;
                        dochadzka_x();
                    } elseif ($_GET['akc'] == 13) {
                        pristup("admin");
                        jazyky();
                    } elseif ($_GET['akc'] == 14) {
                        pristup("zamx");
                        docs_zamx();
                    } elseif ($_GET['akc'] == 15) {
                        pristup("zamestnanec");
                        if (Empty($_GET['akc2']) && Empty($_GET['zid'])) {
                            vp();
                        } elseif ($_GET['akc2'] == 2 && !Empty($_GET['zid'])) {
                            $zid = IntVal($_GET['zid']);
                            vp_zid("$zid");
                        }
                    } elseif ($_GET['akc'] == 16) {
                        pristup("zamx");
                        vp_zamx();
                    } else {
                        
                    }
                    ?>

                </td></tr></table>
    </body>
</html>